package com.miao.UserClass;

import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;


public class MyTypeFilter implements TypeFilter {

    /**
     * Description: 自定义过滤规则:
     *
     * metadataReader ----》当前扫描类的元数据
     * metadataReaderFactory ---》可以获取任意类的元数据
     *
     * Author: Miao@ShaoQing
     * Data: 10:54 2021/3/31
     */
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {

        //类名字中含有 ple 的表示命中
        //当前类的 元数据
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        String className = classMetadata.getClassName();
        if(className.contains("ple")){
            return true;
        }
        return false;
    }
}
